package com.aipsi.cws.common.customAssert;


import com.aipsi.cws.common.exception.CustomException;
import com.aipsi.cws.common.exception.CustomExceptionType;

/**
 * <p>
 *    自定义断言类
 * </p>
 * @author 大忽悠
 * @create 2022/3/25 20:26
 */
public class Assert {
    public static void isTrue(boolean expression, String message) {
        if (!expression) {
            throw new CustomException(message);
        }
    }

    public static void isTrue(boolean expression, String message,Class exClass) {
        if (!expression) {
            throw new CustomException(message);
        }
    }

    public static void isTrue(boolean expression, CustomExceptionType exceptionType) {
        if (!expression) {
            throw new CustomException(exceptionType);
        }
    }

    public static void isNull(Object object, String message) {
        if (object != null) {
            throw new CustomException(message);
        }
    }

    public static void isNull(Object object,CustomExceptionType exceptionType) {
        if (object != null) {
            throw new CustomException(exceptionType);
        }
    }

    public static void notNull(Object object, String message) {
        if (object == null) {
            throw new CustomException(message);
        }
    }

    public static void notNull(Object object,CustomExceptionType exceptionType) {
        if (object == null) {
            throw new CustomException(exceptionType);
        }
    }
}
